home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat2 / standard / profil.z / profil
Encoding:
Text File  |  2002-10-03  |  6.1 KB  |  133 lines

  1.  
  2.  
  3.  
  4. pppprrrrooooffffiiiillll((((2222))))                                                            pppprrrrooooffffiiiillll((((2222))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      pppprrrrooooffffiiiillll ---- eeeexxxxeeeeccccuuuuttttiiiioooonnnn ttttiiiimmmmeeee pppprrrrooooffffiiiilllleeee
  10.  
  11. CCCC SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      iiiinnnntttt pppprrrrooooffffiiiillll ((((uuuunnnnssssiiiiggggnnnneeeedddd sssshhhhoooorrrrtttt ****bbbbuuuuffffffff,,,, uuuunnnnssssiiiiggggnnnneeeedddd iiiinnnntttt bbbbuuuuffffssssiiiizzzz,,,,
  13.                uuuunnnnssssiiiiggggnnnneeeedddd iiiinnnntttt ooooffffffffsssseeeetttt,,,, uuuunnnnssssiiiiggggnnnneeeedddd iiiinnnntttt ssssccccaaaalllleeee))));;;;
  14.  
  15. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  16.      pppprrrrooooffffiiiillll provides CPU-use statistics by profiling the amount of CPU time
  17.      expended by a program. pppprrrrooooffffiiiillll generates the statistics by creating an
  18.      execution histogram for a current process.  The histogram is defined for
  19.      a specific region of program code to be profiled, and the identified
  20.      region is logically broken up into a set of equal size subdivisions, each
  21.      of which corresponds to a count in the histogram.  With each clock tick,
  22.      the current subdivision is identified and its corresponding histogram
  23.      count is incremented.  These counts establish a relative measure of how
  24.      much time is being spent in each code subdivision.  The resulting
  25.      histogram counts for a profiled region can be used to identify those
  26.      functions that consume a disproportionately high percentage of CPU time.
  27.  
  28.      _b_u_f_f is a buffer of _b_u_f_s_i_z bytes in which the histogram counts are stored
  29.      in an array of uuuunnnnssssiiiiggggnnnneeeedddd sssshhhhoooorrrrtttt iiiinnnntttt....
  30.  
  31.      _o_f_f_s_e_t, _s_c_a_l_e, and _b_u_f_s_i_z specify the region to be profiled.
  32.  
  33.      _o_f_f_s_e_t is effectively the start address of the region to be profiled.
  34.  
  35.      _s_c_a_l_e, broadly speaking, is a contraction factor that indicates how much
  36.      smaller the histogram buffer is than the region to be profiled.  More
  37.      precisely, _s_c_a_l_e is interpreted as an unsigned 16-bit fixed-point
  38.      fraction with the decimal point implied on the left.  Its value is the
  39.      reciprocal of the number of instructions in a subdivision, per counter of
  40.      histogram buffer.
  41.  
  42.      Several observations can be made:
  43.  
  44.         -    the maximal value of _s_c_a_l_e, 0x10000, gives a 1-1 mapping of pc's
  45.              to 4-byte words in _b_u_f_f.  This value makes no sense for the
  46.              default 16-bit (2-byte) counters, since this means 2 bytes of
  47.              wasted space for every 2 bytes of counter.
  48.  
  49.         -    the minimum value of _s_c_a_l_e (for which profiling is performed),
  50.              0x0002 (1/32,768), maps (by convention) the entire region
  51.              starting with _o_f_f_s_e_t to the first counter in _b_u_f_f.
  52.  
  53.         -    a _s_c_a_l_e value of 0x8000 specifies a contraction of two, which
  54.              means every 4-byte instruction maps to 2 bytes of counter space.
  55.              For 16-bit counters this means a 1-1 mapping of instructions to
  56.              counters.  For 32-bit counters (see sssspppprrrrooooffffiiiillll((((2222))))) this means two
  57.              4-byte instructions map to each 4-byte counter.
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. pppprrrrooooffffiiiillll((((2222))))                                                            pppprrrrooooffffiiiillll((((2222))))
  71.  
  72.  
  73.  
  74.      The values are used within the kernel as follows:  when the process is
  75.      interrupted for a clock tick (once every 10 milliseconds), the value of
  76.      _o_f_f_s_e_t is subtracted from the current value of the program counter (pc),
  77.      and the remainder is multiplied by _s_c_a_l_e to derive a result.  That result
  78.      is used as an index into the histogram array to locate the cell to be
  79.      incremented.  Therefore, the cell count represents the number of times
  80.      that the process was executing code in the subdivision associated with
  81.      that cell when the process was interrupted.
  82.  
  83.      Since each cell is only 16 bits wide, it is conceivable for it to
  84.      overflow. No indication that this has occurred is given.  If an overflow
  85.      is likely, it is recommended that the alternative sssspppprrrrooooffffiiiillll((((2222)))) be used,
  86.      which supports a superset of pppprrrrooooffffiiiillll((((2222)))) functionality and supports using
  87.      optional 32-bit cells.
  88.  
  89. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  90.      sprofil(2), prof(1), times(2), monitor(3X), fork(2), sproc(2).
  91.  
  92. NNNNOOOOTTTTEEEESSSS
  93.      Profiling is turned off by giving a _s_c_a_l_e of 0 or 1, and is rendered
  94.      ineffective by giving a _b_u_f_s_i_z of 0.  Profiling is turned off when an
  95.      eeeexxxxeeeecccc((((2222)))) is executed, but remains on in both child and parent processes
  96.      after a ffffoooorrrrkkkk (2) or sssspppprrrroooocccc((((2222)))).... Profiling is turned off if a _b_u_f_f update
  97.      would cause a memory fault.
  98.  
  99. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  100.      A 0, indicating success, is always returned.
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.